<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button onclick="add()">添加歌曲</button>
    <ul>
        <!-- <li>
            <audio src="music/music1.mp3"></audio>
        </li> -->
    </ul>
    <script>
        let musics=["./music/music1.mp3","./music/music1.mp3","./music/music1.mp3"]
        index=0
        function add(){
            if(index==musics.length){
                alert("添加歌曲完毕")
                return;
            }
            let ul=document.querySelector("ul")
            // let li=document.createElement("li")
            // let audio=document.createElement("audio")
            // audio.setAttribute("controls","")
            // audio.setAttribute("src",musics[index++])
            // li.appendChild(audio)
            // ul.appendChild(li)
            ul.innerHTML+=`
                <li>
                    <audio controls src="${musics[index++]}"></audio>
                </li>
            `
        }
    </script>
</body>
</html>